package com.empire.module.spider.controller.app.lotteryfootballgamezucaisfc;

import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import org.springframework.validation.annotation.Validated;

import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;

import javax.validation.constraints.*;
import javax.validation.*;
import javax.servlet.http.*;
import java.util.*;
import java.io.IOException;

import com.empire.framework.common.pojo.PageParam;
import com.empire.framework.common.pojo.PageResult;
import com.empire.framework.common.pojo.CommonResult;
import com.empire.framework.common.util.object.BeanUtils;
import static com.empire.framework.common.pojo.CommonResult.success;

import com.empire.framework.excel.core.util.ExcelUtils;

import com.empire.framework.apilog.core.annotation.ApiAccessLog;
import static com.empire.framework.apilog.core.enums.OperateTypeEnum.*;

import com.empire.module.spider.controller.app.lotteryfootballgamezucaisfc.vo.*;
import com.empire.module.spider.dal.dataobject.lotteryfootballgamezucaisfc.LotteryFootballGameZucaiSfcDO;
import com.empire.module.spider.service.lotteryfootballgamezucaisfc.LotteryFootballGameZucaiSfcService;

@Tag(name = "用户 APP - 足彩胜负彩、任九比赛")
@RestController
@RequestMapping("/spider/lottery-football-game-zucai-sfc")
@Validated
public class AppLotteryFootballGameZucaiSfcController {

    @Resource
    private LotteryFootballGameZucaiSfcService lotteryFootballGameZucaiSfcService;

    @PostMapping("/create")
    @Operation(summary = "创建足彩胜负彩、任九比赛")
    public CommonResult<String> createLotteryFootballGameZucaiSfc(@Valid @RequestBody AppLotteryFootballGameZucaiSfcSaveReqVO createReqVO) {
        return success(lotteryFootballGameZucaiSfcService.createLotteryFootballGameZucaiSfc(createReqVO));
    }

    @PutMapping("/update")
    @Operation(summary = "更新足彩胜负彩、任九比赛")
    public CommonResult<Boolean> updateLotteryFootballGameZucaiSfc(@Valid @RequestBody AppLotteryFootballGameZucaiSfcSaveReqVO updateReqVO) {
        lotteryFootballGameZucaiSfcService.updateLotteryFootballGameZucaiSfc(updateReqVO);
        return success(true);
    }

    @DeleteMapping("/delete")
    @Operation(summary = "删除足彩胜负彩、任九比赛")
    @Parameter(name = "id", description = "编号", required = true)
    public CommonResult<Boolean> deleteLotteryFootballGameZucaiSfc(@RequestParam("id") String id) {
        lotteryFootballGameZucaiSfcService.deleteLotteryFootballGameZucaiSfc(id);
        return success(true);
    }

    @GetMapping("/get")
    @Operation(summary = "获得足彩胜负彩、任九比赛")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    public CommonResult<AppLotteryFootballGameZucaiSfcRespVO> getLotteryFootballGameZucaiSfc(@RequestParam("id") String id) {
        LotteryFootballGameZucaiSfcDO lotteryFootballGameZucaiSfc = lotteryFootballGameZucaiSfcService.getLotteryFootballGameZucaiSfc(id);
        return success(BeanUtils.toBean(lotteryFootballGameZucaiSfc, AppLotteryFootballGameZucaiSfcRespVO.class));
    }

    @GetMapping("/page")
    @Operation(summary = "获得足彩胜负彩、任九比赛分页")
    public CommonResult<PageResult<AppLotteryFootballGameZucaiSfcRespVO>> getLotteryFootballGameZucaiSfcPage(@Valid AppLotteryFootballGameZucaiSfcPageReqVO pageReqVO) {
        PageResult<LotteryFootballGameZucaiSfcDO> pageResult = lotteryFootballGameZucaiSfcService.getLotteryFootballGameZucaiSfcPage(pageReqVO);
        return success(BeanUtils.toBean(pageResult, AppLotteryFootballGameZucaiSfcRespVO.class));
    }

    @GetMapping("/export-excel")
    @Operation(summary = "导出足彩胜负彩、任九比赛 Excel")
    @ApiAccessLog(operateType = EXPORT)
    public void exportLotteryFootballGameZucaiSfcExcel(@Valid AppLotteryFootballGameZucaiSfcPageReqVO pageReqVO,
              HttpServletResponse response) throws IOException {
        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
        List<LotteryFootballGameZucaiSfcDO> list = lotteryFootballGameZucaiSfcService.getLotteryFootballGameZucaiSfcPage(pageReqVO).getList();
        // 导出 Excel
        ExcelUtils.write(response, "足彩胜负彩、任九比赛.xls", "数据", AppLotteryFootballGameZucaiSfcRespVO.class,
                        BeanUtils.toBean(list, AppLotteryFootballGameZucaiSfcRespVO.class));
    }

}
